<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>spade.xmpp.transports.TCPsocket</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="spade-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spade2.googlecode.com">SPADE</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="spade-module.html">Package&nbsp;spade</a> ::
        <a href="spade.xmpp-module.html">Package&nbsp;xmpp</a> ::
        <a href="spade.xmpp.transports-module.html">Module&nbsp;transports</a> ::
        Class&nbsp;TCPsocket
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="spade.xmpp.transports.TCPsocket-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class TCPsocket</h1><p class="nomargin-top"><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_spade_xm_55" name="uml_class_diagram_for_spade_xm_55">
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#__init__" title="Cache connection point &#39;server&#39;." alt="" coords="17,153,269,172"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#plugin" title="Fire up connection." alt="" coords="17,172,269,191"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#getHost" title="Return the &#39;host&#39; value that is connection is [will be] made to." alt="" coords="17,191,269,209"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#getPort" title="Return the &#39;port&#39; value that is connection is [will be] made to." alt="" coords="17,209,269,228"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#connect" title="Try to connect." alt="" coords="17,228,269,247"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#plugout" title="Disconnect from the remote server and unregister self.disconnected method &#160;from the owner&#39;s dispatcher." alt="" coords="17,247,269,265"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#receive" title="Reads all pending incoming data." alt="" coords="17,265,269,284"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#send" title="Writes raw outgoing data." alt="" coords="17,284,269,303"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#pending_data" title="Returns true if there is a data ready to be read." alt="" coords="17,303,269,321"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#disconnect" title="Closes the socket." alt="" coords="17,321,269,340"/>
<area shape="rect" id="node2682" href="spade.xmpp.transports.TCPsocket-class.html#disconnected" title="Called when a Network Error or disconnection occurs." alt="" coords="17,340,269,359"/>
<area shape="rect" id="node1" href="spade.xmpp.transports.TCPsocket-class.html" title="This class defines direct TCP connection method." alt="" coords="5,121,280,365"/>
<area shape="rect" id="node3" href="spade.xmpp.transports.HTTPPROXYsocket-class.html" title="HTTP (CONNECT) proxy connection class." alt="" coords="65,385,223,423"/>
<area shape="rect" id="node2683" href="spade.xmpp.client.PlugIn-class.html#DEBUG" title="Feed a provided debug line to main instance&#39;s debug facility along with our ID string." alt="" coords="41,39,245,57"/>
<area shape="rect" id="node2683" href="spade.xmpp.client.PlugIn-class.html#PlugIn" title="Attach to main instance and register ourself and all our staff in it." alt="" coords="41,57,245,76"/>
<area shape="rect" id="node2683" href="spade.xmpp.client.PlugIn-class.html#PlugOut" title="Unregister all our staff from main instance and detach from it." alt="" coords="41,76,245,95"/>
<area shape="rect" id="node2" href="spade.xmpp.client.PlugIn-class.html" title="Common xmpppy plugins infrastructure: plugging in/out, debugging." alt="" coords="29,6,256,101"/>
</map>
  <img src="uml_class_diagram_for_spade_xm_55.gif" alt='' usemap="#uml_class_diagram_for_spade_xm_55" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<p>This class defines direct TCP connection method.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.xmpp.transports.TCPsocket-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">server</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">use_srv</span>=<span class="summary-sig-default">True</span>)</span><br />
      Cache connection point 'server'.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.xmpp.transports.TCPsocket-class.html#plugin" class="summary-sig-name">plugin</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">owner</span>)</span><br />
      Fire up connection.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.plugin">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="getHost"></a><span class="summary-sig-name">getHost</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the 'host' value that is connection is [will be] made to.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.getHost">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="getPort"></a><span class="summary-sig-name">getPort</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the 'port' value that is connection is [will be] made to.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.getPort">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.xmpp.transports.TCPsocket-class.html#connect" class="summary-sig-name">connect</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">server</span>=<span class="summary-sig-default">None</span>)</span><br />
      Try to connect.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.connect">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="plugout"></a><span class="summary-sig-name">plugout</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Disconnect from the remote server and unregister self.disconnected 
      method from the owner's dispatcher.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.plugout">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.xmpp.transports.TCPsocket-class.html#receive" class="summary-sig-name">receive</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Reads all pending incoming data.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.receive">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.xmpp.transports.TCPsocket-class.html#send" class="summary-sig-name">send</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">raw_data</span>)</span><br />
      Writes raw outgoing data.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.send">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="pending_data"></a><span class="summary-sig-name">pending_data</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">timeout</span>=<span class="summary-sig-default">0</span>)</span><br />
      Returns true if there is a data ready to be read.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.pending_data">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="disconnect"></a><span class="summary-sig-name">disconnect</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Closes the socket.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.disconnect">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.xmpp.transports.TCPsocket-class.html#disconnected" class="summary-sig-name">disconnected</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Called when a Network Error or disconnection occurs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.disconnected">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="spade.xmpp.client.PlugIn-class.html">client.PlugIn</a></code></b>:
      <code><a href="spade.xmpp.client.PlugIn-class.html#DEBUG">DEBUG</a></code>,
      <code><a href="spade.xmpp.client.PlugIn-class.html#PlugIn">PlugIn</a></code>,
      <code><a href="spade.xmpp.client.PlugIn-class.html#PlugOut">PlugOut</a></code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">server</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">use_srv</span>=<span class="sig-default">True</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Cache connection point 'server'. 'server' is the tuple of (host, port)
  absolutely the same as standard tcp socket uses.</p>
  <dl class="fields">
    <dt>Overrides:
        <a href="spade.xmpp.client.PlugIn-class.html#__init__">client.PlugIn.__init__</a>
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="plugin"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">plugin</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">owner</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.plugin">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Fire up connection. Return non-empty string on success. Also registers
  self.disconnected method in the owner's dispatcher. Called 
  internally.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="connect"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">connect</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">server</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.connect">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Try to connect. Returns non-empty string on success.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="receive"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">receive</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.receive">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Reads all pending incoming data. In case of disconnection calls 
  owner's disconnected() method and then raises IOError exception.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="send"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">send</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">raw_data</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.send">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Writes raw outgoing data. Blocks until done. If supplied data is 
  unicode string, encodes it to utf-8 before send.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="disconnected"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">disconnected</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.xmpp.transports-pysrc.html#TCPsocket.disconnected">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Called when a Network Error or disconnection occurs. Designed to be 
  overidden.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="spade-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spade2.googlecode.com">SPADE</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed Aug  1 18:44:59 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
